package com.zzedu.controller;

import com.zzedu.common.annotation.Log;
import com.zzedu.common.core.controller.BaseController;
import com.zzedu.common.core.domain.AjaxResult;
import com.zzedu.common.core.page.TableDataInfo;
import com.zzedu.common.enums.BusinessType;
import com.zzedu.common.utils.ServletUtils;
import com.zzedu.common.utils.poi.ExcelUtil;
import com.zzedu.domain.ZzStuLog;
import com.zzedu.dto.ZzStuLogDTO;
import com.zzedu.service.IZzStuLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 学生续费、分班日志Controller
 * 
 * @author Mr.Wang
 * @date 2025-06-08
 */
@RestController
@RequestMapping("/school/stulog")
public class ZzStuLogController extends BaseController
{
    @Autowired
    private IZzStuLogService zzStuLogService;

    /**
     * 查询学生续费、分班日志列表
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:stulog:query')")
    @RequestMapping("/list")
    public TableDataInfo list(@RequestBody ZzStuLogDTO zzStuLog)
    {
        return getDataTable(zzStuLogService.page(zzStuLog.getPageDTO(),zzStuLogService.buildQuery(zzStuLog)));
    }

    /**
     * 导出学生续费、分班日志列表
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:stulog:export')")
    @Log(title = "学生续费、分班日志", businessType = BusinessType.EXPORT)
    @RequestMapping("/export")
    public void export(ZzStuLogDTO zzStuLog)
    {
        List<ZzStuLog> list = zzStuLogService.list(zzStuLogService.buildQuery(zzStuLog));
        ExcelUtil<ZzStuLog> util = new ExcelUtil<ZzStuLog>(ZzStuLog.class);
        util.exportExcel(ServletUtils.getResponse(),list, "学生续费、分班日志数据");
    }




    /**
     * 新增保存学生续费、分班日志
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:stulog:add')")
    @Log(title = "学生续费、分班日志", businessType = BusinessType.INSERT)
    @RequestMapping("/add")
    public AjaxResult addSave(@Validated @RequestBody ZzStuLog zzStuLog)
    {
        return toAjax(zzStuLogService.save(zzStuLog));
    }



    /**
     * 获取学生续费、分班日志详细信息
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:stulog:query')")
    @RequestMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zzStuLogService.getById(id));
    }


    /**
     * 修改保存学生续费、分班日志
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:stulog:edit')")
    @Log(title = "学生续费、分班日志", businessType = BusinessType.UPDATE)
    @RequestMapping("/edit")
    public AjaxResult editSave(@Validated @RequestBody ZzStuLog zzStuLog)
    {
        return toAjax(zzStuLogService.updateById(zzStuLog));
    }

    /**
     * 删除学生续费、分班日志
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:stulog:remove')")
    @Log(title = "学生续费、分班日志", businessType = BusinessType.DELETE)
	@RequestMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(zzStuLogService.removeBatchByIds(ids));
    }
}
